package com.online.controller;

import com.online.entity.ApiResult;
import com.online.entity.FillQuestion;
import com.online.service.FillQuestionService;
import com.online.util.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 填空题
 */
@RestController
public class FillQuestionController {
    @Autowired
    private FillQuestionService fillQuestionService;

    @PostMapping("/fillQuestion")
    public ApiResult add(@RequestBody FillQuestion fillQuestion){
        int res = fillQuestionService.add(fillQuestion);
        if (res != 0) {
            return ApiResultHandler.buildApiResult(200,"添加成功",res);
        }
        return ApiResultHandler.buildApiResult(400,"添加失败",res);

    }
    @GetMapping("/fillQuestionId")
    public ApiResult findOnlyQuestionId(){
        FillQuestion res = fillQuestionService.findOnlyQuestionId();
        return ApiResultHandler.buildApiResult(200,"查询成功",res);

    }
}
